home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmlyac / output.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-03  |  15.2 KB  |  894 lines  |  [TEXT/R*ch]

  1. #include "defs.h"
  2.  
  3. static int nvectors;
  4. static int nentries;
  5. static short **froms;
  6. static short **tos;
  7. static short *tally;
  8. static short *width;
  9. static short *state_count;
  10. static short *order;
  11. static short *base;
  12. static short *pos;
  13. static int maxtable;
  14. static short *table;
  15. static short *check;
  16. static int lowzero;
  17. static int high;
  18.  
  19.  
  20. output()
  21. {
  22.   extern char *header[], *define_tables[];
  23.  
  24.   free_itemsets();
  25.   free_shifts();
  26.   free_reductions();
  27.   write_section(header);
  28.   output_stored_text();
  29.   output_transl();
  30.   output_rule_data();
  31.   output_yydefred();
  32.   output_actions();
  33.   free_parser();
  34.   output_debug();
  35.   fprintf(output_file,
  36.      "val yyact = vector_ %d (fn () => ((raise Fail \"parser\") : obj));\n",
  37.      ntotalrules);
  38.   output_semantic_actions();
  39.   write_section(define_tables);
  40.   output_entries();
  41.   output_trailing_text();
  42. }
  43.  
  44.  
  45. static void output_char(n)
  46.      unsigned n;
  47. {
  48.   n = n & 0xFF;
  49.   putc('\\', output_file);
  50.   putc('0' + n / 100, output_file);
  51.   putc('0' + (n / 10) % 10, output_file);
  52.   putc('0' + n % 10, output_file);
  53. }
  54.  
  55. static void output_short(n)
  56.      int n;
  57. {
  58.   output_char(n);
  59.   output_char(n >> 8);
  60. }
  61.  
  62. output_rule_data()
  63. {
  64.     register int i;
  65.     register int j;
  66.  
  67.  
  68.     fprintf(output_file, "val yylhs = \"");
  69.     output_short(symbol_value[start_symbol]);
  70.  
  71.     j = 8;
  72.     for (i = 3; i < nrules; i++)
  73.     {
  74.     if (j >= 8)
  75.     {
  76.         if (!rflag) ++outline;
  77.             fprintf(output_file, "\\\n\\");
  78.         j = 1;
  79.     }
  80.         else
  81.         ++j;
  82.  
  83.         output_short(symbol_value[rlhs[i]]);
  84.     }
  85.     if (!rflag) outline += 2;
  86.     fprintf(output_file, "\";\n\n");
  87.  
  88.     fprintf(output_file, "val yylen = \"");
  89.     output_short(2);
  90.  
  91.     j = 8;
  92.     for (i = 3; i < nrules; i++)
  93.     {
  94.     if (j >= 8)
  95.     {
  96.         if (!rflag) ++outline;
  97.             fprintf(output_file, "\\\n\\");
  98.         j = 1;
  99.     }
  100.     else
  101.       j++;
  102.  
  103.         output_short(rrhs[i + 1] - rrhs[i] - 1);
  104.     }
  105.     if (!rflag) outline += 2;
  106.     fprintf(output_file, "\";\n\n");
  107. }
  108.  
  109.  
  110. output_yydefred()
  111. {
  112.     register int i, j;
  113.  
  114.     fprintf(output_file, "val yydefred = \"");
  115.     output_short(defred[0] ? defred[0] - 2 : 0);
  116.  
  117.     j = 8;
  118.     for (i = 1; i < nstates; i++)
  119.     {
  120.     if (j < 8)
  121.         ++j;
  122.     else
  123.     {
  124.         if (!rflag) ++outline;
  125.             fprintf(output_file, "\\\n\\");
  126.         j = 1;
  127.     }
  128.  
  129.     output_short(defred[i] ? defred[i] - 2 : 0);
  130.     }
  131.  
  132.     if (!rflag) outline += 2;
  133.     fprintf(output_file, "\";\n\n");
  134. }
  135.  
  136.  
  137. output_actions()
  138. {
  139.     nvectors = 2*nstates + nvars;
  140.  
  141.     froms = NEW2(nvectors, short *);
  142.     tos = NEW2(nvectors, short *);
  143.     tally = NEW2(nvectors, short);
  144.     width = NEW2(nvectors, short);
  145.  
  146.     token_actions();
  147.     FREE(lookaheads);
  148.     FREE(LA);
  149.     FREE(LAruleno);
  150.     FREE(accessing_symbol);
  151.  
  152.     goto_actions();
  153.     FREE(goto_map + ntokens);
  154.     FREE(from_state);
  155.     FREE(to_state);
  156.  
  157.     sort_actions();
  158.     pack_table();
  159.     output_base();
  160.     output_table();
  161.     output_check();
  162. }
  163.  
  164.  
  165. token_actions()
  166. {
  167.     register int i, j;
  168.     register int shiftcount, reducecount;
  169.     register int max, min;
  170.     register short *actionrow, *r, *s;
  171.     register action *p;
  172.  
  173.     actionrow = NEW2(2*ntokens, short);
  174.     for (i = 0; i < nstates; ++i)
  175.     {
  176.     if (parser[i])
  177.     {
  178.         for (j = 0; j < 2*ntokens; ++j)
  179.         actionrow[j] = 0;
  180.  
  181.         shiftcount = 0;
  182.         reducecount = 0;
  183.         for (p = parser[i]; p; p = p->next)
  184.         {
  185.         if (p->suppressed == 0)
  186.         {
  187.             if (p->action_code == SHIFT)
  188.             {
  189.             ++shiftcount;
  190.             actionrow[p->symbol] = p->number;
  191.             }
  192.             else if (p->action_code == REDUCE && p->number != defred[i])
  193.             {
  194.             ++reducecount;
  195.             actionrow[p->symbol + ntokens] = p->number;
  196.             }
  197.         }
  198.         }
  199.  
  200.         tally[i] = shiftcount;
  201.         tally[nstates+i] = reducecount;
  202.         width[i] = 0;
  203.         width[nstates+i] = 0;
  204.         if (shiftcount > 0)
  205.         {
  206.         froms[i] = r = NEW2(shiftcount, short);
  207.         tos[i] = s = NEW2(shiftcount, short);
  208.         min = MAXSHORT;
  209.         max = 0;
  210.         for (j = 0; j < ntokens; ++j)
  211.         {
  212.             if (actionrow[j])
  213.             {
  214.             if (min > symbol_value[j])
  215.                 min = symbol_value[j];
  216.             if (max < symbol_value[j])
  217.                 max = symbol_value[j];
  218.             *r++ = symbol_value[j];
  219.             *s++ = actionrow[j];
  220.             }
  221.         }
  222.         width[i] = max - min + 1;
  223.         }
  224.         if (reducecount > 0)
  225.         {
  226.         froms[nstates+i] = r = NEW2(reducecount, short);
  227.         tos[nstates+i] = s = NEW2(reducecount, short);
  228.         min = MAXSHORT;
  229.         max = 0;
  230.         for (j = 0; j < ntokens; ++j)
  231.         {
  232.             if (actionrow[ntokens+j])
  233.             {
  234.             if (min > symbol_value[j])
  235.                 min = symbol_value[j];
  236.             if (max < symbol_value[j])
  237.                 max = symbol_value[j];
  238.             *r++ = symbol_value[j];
  239.             *s++ = actionrow[ntokens+j] - 2;
  240.             }
  241.         }
  242.         width[nstates+i] = max - min + 1;
  243.         }
  244.     }
  245.     }
  246.     FREE(actionrow);
  247. }
  248.  
  249. goto_actions()
  250. {
  251.     register int i, j, k;
  252.  
  253.     state_count = NEW2(nstates, short);
  254.  
  255.     k = default_goto(start_symbol + 1);
  256.     fprintf(output_file, "val yydgoto = \"");
  257.     output_short(k);
  258.  
  259.     save_column(start_symbol + 1, k);
  260.  
  261.     j = 8;
  262.     for (i = start_symbol + 2; i < nsyms; i++)
  263.     {
  264.     if (j >= 8)
  265.     {
  266.         if (!rflag) ++outline;
  267.             fprintf(output_file, "\\\n\\");
  268.         j = 1;
  269.     }
  270.     else
  271.         ++j;
  272.  
  273.     k = default_goto(i);
  274.     output_short(k);
  275.     save_column(i, k);
  276.     }
  277.  
  278.     if (!rflag) outline += 2;
  279.     fprintf(output_file, "\";\n\n");
  280.     FREE(state_count);
  281. }
  282.  
  283. int
  284. default_goto(symbol)
  285. int symbol;
  286. {
  287.     register int i;
  288.     register int m;
  289.     register int n;
  290.     register int default_state;
  291.     register int max;
  292.  
  293.     m = goto_map[symbol];
  294.     n = goto_map[symbol + 1];
  295.  
  296.     if (m == n) return (0);
  297.  
  298.     for (i = 0; i < nstates; i++)
  299.     state_count[i] = 0;
  300.  
  301.     for (i = m; i < n; i++)
  302.     state_count[to_state[i]]++;
  303.  
  304.     max = 0;
  305.     default_state = 0;
  306.     for (i = 0; i < nstates; i++)
  307.     {
  308.     if (state_count[i] > max)
  309.     {
  310.         max = state_count[i];
  311.         default_state = i;
  312.     }
  313.     }
  314.  
  315.     return (default_state);
  316. }
  317.  
  318.  
  319.  
  320. save_column(symbol, default_state)
  321. int symbol;
  322. int default_state;
  323. {
  324.     register int i;
  325.     register int m;
  326.     register int n;
  327.     register short *sp;
  328.     register short *sp1;
  329.     register short *sp2;
  330.     register int count;
  331.     register int symno;
  332.  
  333.     m = goto_map[symbol];
  334.     n = goto_map[symbol + 1];
  335.  
  336.     count = 0;
  337.     for (i = m; i < n; i++)
  338.     {
  339.     if (to_state[i] != default_state)
  340.         ++count;
  341.     }
  342.     if (count == 0) return;
  343.  
  344.     symno = symbol_value[symbol] + 2*nstates;
  345.  
  346.     froms[symno] = sp1 = sp = NEW2(count, short);
  347.     tos[symno] = sp2 = NEW2(count, short);
  348.  
  349.     for (i = m; i < n; i++)
  350.     {
  351.     if (to_state[i] != default_state)
  352.     {
  353.         *sp1++ = from_state[i];
  354.         *sp2++ = to_state[i];
  355.     }
  356.     }
  357.  
  358.     tally[symno] = count;
  359.     width[symno] = sp1[-1] - sp[0] + 1;
  360. }
  361.  
  362. sort_actions()
  363. {
  364.   register int i;
  365.   register int j;
  366.   register int k;
  367.   register int t;
  368.   register int w;
  369.  
  370.   order = NEW2(nvectors, short);
  371.   nentries = 0;
  372.  
  373.   for (i = 0; i < nvectors; i++)
  374.     {
  375.       if (tally[i] > 0)
  376.     {
  377.       t = tally[i];
  378.       w = width[i];
  379.       j = nentries - 1;
  380.  
  381.       while (j >= 0 && (width[order[j]] < w))
  382.         j--;
  383.  
  384.       while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
  385.         j--;
  386.  
  387.       for (k = nentries - 1; k > j; k--)
  388.         order[k + 1] = order[k];
  389.  
  390.       order[j + 1] = i;
  391.       nentries++;
  392.     }
  393.     }
  394. }
  395.  
  396.  
  397. pack_table()
  398. {
  399.     register int i;
  400.     register int place;
  401.     register int state;
  402.  
  403.     base = NEW2(nvectors, short);
  404.     pos = NEW2(nentries, short);
  405.  
  406.     maxtable = 1000;
  407.     table = NEW2(maxtable, short);
  408.     check = NEW2(maxtable, short);
  409.  
  410.     lowzero = 0;
  411.     high = 0;
  412.  
  413.     for (i = 0; i < maxtable; i++)
  414.     check[i] = -1;
  415.  
  416.     for (i = 0; i < nentries; i++)
  417.     {
  418.     state = matching_vector(i);
  419.  
  420.     if (state < 0)
  421.         place = pack_vector(i);
  422.     else
  423.         place = base[state];
  424.  
  425.     pos[i] = place;
  426.     base[order[i]] = place;
  427.     }
  428.  
  429.     for (i = 0; i < nvectors; i++)
  430.     {
  431.     if (froms[i])
  432.         FREE(froms[i]);
  433.     if (tos[i])
  434.         FREE(tos[i]);
  435.     }
  436.  
  437.     FREE(froms);
  438.     FREE(tos);
  439.     FREE(pos);
  440. }
  441.  
  442.  
  443. /*  The function matching_vector determines if the vector specified by    */
  444. /*  the input parameter matches a previously considered    vector.  The    */
  445. /*  test at the start of the function checks if the vector represents    */
  446. /*  a row of shifts over terminal symbols or a row of reductions, or a    */
  447. /*  column of shifts over a nonterminal symbol.  Berkeley Yacc does not    */
  448. /*  check if a column of shifts over a nonterminal symbols matches a    */
  449. /*  previously considered vector.  Because of the nature of LR parsing    */
  450. /*  tables, no two columns can match.  Therefore, the only possible    */
  451. /*  match would be between a row and a column.  Such matches are    */
  452. /*  unlikely.  Therefore, to save time, no attempt is made to see if a    */
  453. /*  column matches a previously considered vector.            */
  454. /*                                    */
  455. /*  Matching_vector is poorly designed.  The test could easily be made    */
  456. /*  faster.  Also, it depends on the vectors being in a specific    */
  457. /*  order.                                */
  458.  
  459. int
  460. matching_vector(vector)
  461. int vector;
  462. {
  463.     register int i;
  464.     register int j;
  465.     register int k;
  466.     register int t;
  467.     register int w;
  468.     register int match;
  469.     register int prev;
  470.  
  471.     i = order[vector];
  472.     if (i >= 2*nstates)
  473.     return (-1);
  474.  
  475.     t = tally[i];
  476.     w = width[i];
  477.  
  478.     for (prev = vector - 1; prev >= 0; prev--)
  479.     {
  480.     j = order[prev];
  481.     if (width[j] != w || tally[j] != t)
  482.         return (-1);
  483.  
  484.     match = 1;
  485.     for (k = 0; match && k < t; k++)
  486.     {
  487.         if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k])
  488.         match = 0;
  489.     }
  490.  
  491.     if (match)
  492.         return (j);
  493.     }
  494.  
  495.     return (-1);
  496. }
  497.  
  498.  
  499.  
  500. int
  501. pack_vector(vector)
  502. int vector;
  503. {
  504.     register int i, j, k, l;
  505.     register int t;
  506.     register int loc;
  507.     register int ok;
  508.     register short *from;
  509.     register short *to;
  510.     int newmax;
  511.  
  512.     i = order[vector];
  513.     t = tally[i];
  514.     assert(t);
  515.  
  516.     from = froms[i];
  517.     to = tos[i];
  518.  
  519.     j = lowzero - from[0];
  520.     for (k = 1; k < t; ++k)
  521.     if (lowzero - from[k] > j)
  522.         j = lowzero - from[k];
  523.     for (;; ++j)
  524.     {
  525.     if (j == 0)
  526.         continue;
  527.     ok = 1;
  528.     for (k = 0; ok && k < t; k++)
  529.     {
  530.         loc = j + from[k];
  531.         if (loc >= maxtable)
  532.         {
  533.         if (loc >= MAXTABLE)
  534.             fatal("maximum table size exceeded");
  535.  
  536.         newmax = maxtable;
  537.         do { newmax += 200; } while (newmax <= loc);
  538.         table = (short *) REALLOC(table, newmax*sizeof(short));
  539.         if (table == 0) no_space();
  540.         check = (short *) REALLOC(check, newmax*sizeof(short));
  541.         if (check == 0) no_space();
  542.         for (l  = maxtable; l < newmax; ++l)
  543.         {
  544.             table[l] = 0;
  545.             check[l] = -1;
  546.         }
  547.         maxtable = newmax;
  548.         }
  549.  
  550.         if (check[loc] != -1)
  551.         ok = 0;
  552.     }
  553.     for (k = 0; ok && k < vector; k++)
  554.     {
  555.         if (pos[k] == j)
  556.         ok = 0;
  557.     }
  558.     if (ok)
  559.     {
  560.         for (k = 0; k < t; k++)
  561.         {
  562.         loc = j + from[k];
  563.         table[loc] = to[k];
  564.         check[loc] = from[k];
  565.         if (loc > high) high = loc;
  566.         }
  567.  
  568.         while (check[lowzero] != -1)
  569.         ++lowzero;
  570.  
  571.         return (j);
  572.     }
  573.     }
  574. }
  575.  
  576.  
  577.  
  578. output_base()
  579. {
  580.     register int i, j;
  581.  
  582.     fprintf(output_file, "val yysindex = \"");
  583.     output_short(base[0]);
  584.  
  585.     j = 8;
  586.     for (i = 1; i < nstates; i++)
  587.     {
  588.     if (j >= 8)
  589.     {
  590.         if (!rflag) ++outline;
  591.             fprintf(output_file, "\\\n\\");
  592.         j = 1;
  593.     }
  594.     else
  595.         ++j;
  596.  
  597.     output_short(base[i]);
  598.     }
  599.  
  600.     if (!rflag) outline += 2;
  601.     fprintf(output_file, "\";\n\n");
  602.  
  603.     fprintf(output_file, "val yyrindex = \"");
  604.     output_short(base[nstates]);
  605.  
  606.     j = 8;
  607.     for (i = nstates + 1; i < 2*nstates; i++)
  608.     {
  609.     if (j >= 8)
  610.     {
  611.         if (!rflag) ++outline;
  612.             fprintf(output_file, "\\\n\\");
  613.         j = 1;
  614.     }
  615.     else
  616.         ++j;
  617.  
  618.     output_short(base[i]);
  619.     }
  620.  
  621.     if (!rflag) outline += 2;
  622.     fprintf(output_file, "\";\n\n");
  623.  
  624.     fprintf(output_file, "val yygindex = \"");
  625.     output_short(base[2*nstates]);
  626.  
  627.     j = 8;
  628.     for (i = 2*nstates + 1; i < nvectors - 1; i++)
  629.     {
  630.     if (j >= 8)
  631.     {
  632.         if (!rflag) ++outline;
  633.             fprintf(output_file, "\\\n\\");
  634.         j = 1;
  635.     }
  636.     else
  637.         ++j;
  638.  
  639.     output_short(base[i]);
  640.     }
  641.  
  642.     if (!rflag) outline += 2;
  643.     fprintf(output_file, "\";\n\n");
  644.     FREE(base);
  645. }
  646.  
  647.  
  648.  
  649. output_table()
  650. {
  651.     register int i;
  652.     register int j;
  653.  
  654.     ++outline;
  655.     fprintf(code_file, "val YYTABLESIZE = %d;\n", high);
  656.     fprintf(output_file, "val yytable = \"");
  657.     output_short(table[0]);
  658.  
  659.     j = 8;
  660.     for (i = 1; i <= high; i++)
  661.     {
  662.     if (j >= 8)
  663.     {
  664.         if (!rflag) ++outline;
  665.             fprintf(output_file, "\\\n\\");
  666.         j = 1;
  667.     }
  668.     else
  669.         ++j;
  670.  
  671.     output_short(table[i]);
  672.     }
  673.  
  674.     if (!rflag) outline += 2;
  675.     fprintf(output_file, "\";\n\n");
  676.     FREE(table);
  677. }
  678.  
  679.  
  680.  
  681. output_check()
  682. {
  683.     register int i;
  684.     register int j;
  685.  
  686.     fprintf(output_file, "val yycheck = \"");
  687.     output_short(check[0]);
  688.  
  689.     j = 8;
  690.     for (i = 1; i <= high; i++)
  691.     {
  692.     if (j >= 8)
  693.     {
  694.         if (!rflag) ++outline;
  695.             fprintf(output_file, "\\\n\\");
  696.         j = 1;
  697.     }
  698.     else
  699.         ++j;
  700.  
  701.     output_short(check[i]);
  702.     }
  703.  
  704.     if (!rflag) outline += 2;
  705.     fprintf(output_file, "\";\n\n");
  706.     FREE(check);
  707. }
  708.  
  709. output_transl()
  710. {
  711.   int i;
  712.  
  713.   fprintf(code_file, "val yytransl = #[\n");
  714.   for (i = 0; i < ntokens; i++) {
  715.     if (symbol_true_token[i]) {
  716.       fprintf(code_file, "  %3d (* %s *),\n", symbol_value[i], symbol_name[i]);
  717.     }
  718.   }
  719.   fprintf(code_file, "    0];\n\n");
  720. }
  721.  
  722. output_stored_text()
  723. {
  724.     register int c;
  725.     register FILE *in, *out;
  726.  
  727.     fclose(text_file);
  728.     text_file = fopen(text_file_name, "r");
  729.     if (text_file == NULL)
  730.     open_error(text_file_name);
  731.     in = text_file;
  732.     if ((c = getc(in)) == EOF)
  733.     return;
  734.     out = code_file;
  735.     if (c ==  '\n')
  736.     ++outline;
  737.     putc(c, out);
  738.     while ((c = getc(in)) != EOF)
  739.     {
  740.     if (c == '\n')
  741.         ++outline;
  742.     putc(c, out);
  743.     }
  744.     if (!lflag)
  745.     fprintf(out, line_format, ++outline + 1, code_file_name);
  746. }
  747.  
  748.  
  749. output_debug()
  750. {
  751. }
  752.  
  753. output_trailing_text()
  754. {
  755.     register int c, last;
  756.     register FILE *in, *out;
  757.  
  758.     if (line == 0)
  759.     return;
  760.  
  761.     in = input_file;
  762.     out = code_file;
  763.     c = *cptr;
  764.     if (c == '\n')
  765.     {
  766.     ++lineno;
  767.     if ((c = getc(in)) == EOF)
  768.         return;
  769.     if (!lflag)
  770.     {
  771.         ++outline;
  772.         fprintf(out, line_format, lineno, input_file_name);
  773.     }
  774.     if (c == '\n')
  775.         ++outline;
  776.     putc(c, out);
  777.     last = c;
  778.     }
  779.     else
  780.     {
  781.     if (!lflag)
  782.     {
  783.         ++outline;
  784.         fprintf(out, line_format, lineno, input_file_name);
  785.     }
  786.     do { putc(c, out); } while ((c = *++cptr) != '\n');
  787.     ++outline;
  788.     putc('\n', out);
  789.     last = '\n';
  790.     }
  791.  
  792.     while ((c = getc(in)) != EOF)
  793.     {
  794.     if (c == '\n')
  795.         ++outline;
  796.     putc(c, out);
  797.     last = c;
  798.     }
  799.  
  800.     if (last != '\n')
  801.     {
  802.     ++outline;
  803.     putc('\n', out);
  804.     }
  805.     if (!lflag)
  806.     fprintf(out, line_format, ++outline + 1, code_file_name);
  807. }
  808.  
  809.  
  810. copy_file(file, file_name)
  811.      FILE ** file;
  812.      char * file_name;
  813. {
  814.   register int c, last;
  815.   register FILE *out;
  816.  
  817.   fclose(*file);
  818.     *file = fopen(file_name, "r");
  819.     if (*file == NULL)
  820.     open_error(file_name);
  821.  
  822.     if ((c = getc(*file)) == EOF)
  823.     return;
  824.  
  825.     out = code_file;
  826.     last = c;
  827.     if (c == '\n')
  828.     ++outline;
  829.     putc(c, out);
  830.     while ((c = getc(*file)) != EOF)
  831.     {
  832.     if (c == '\n')
  833.         ++outline;
  834.     putc(c, out);
  835.     last = c;
  836.     }
  837.  
  838.     if (last != '\n')
  839.     {
  840.     ++outline;
  841.     putc('\n', out);
  842.     }
  843.  
  844. }
  845.  
  846. output_semantic_actions()
  847. {
  848.   copy_file (&action_file, action_file_name);
  849. }
  850.  
  851. output_entries()
  852. {
  853.   copy_file (&entry_file, entry_file_name);
  854. }
  855.  
  856. free_itemsets()
  857. {
  858.     register core *cp, *next;
  859.  
  860.     FREE(state_table);
  861.     for (cp = first_state; cp; cp = next)
  862.     {
  863.     next = cp->next;
  864.     FREE(cp);
  865.     }
  866. }
  867.  
  868.  
  869. free_shifts()
  870. {
  871.     register shifts *sp, *next;
  872.  
  873.     FREE(shift_table);
  874.     for (sp = first_shift; sp; sp = next)
  875.     {
  876.     next = sp->next;
  877.     FREE(sp);
  878.     }
  879. }
  880.  
  881.  
  882.  
  883. free_reductions()
  884. {
  885.     register reductions *rp, *next;
  886.  
  887.     FREE(reduction_table);
  888.     for (rp = first_reduction; rp; rp = next)
  889.     {
  890.     next = rp->next;
  891.     FREE(rp);
  892.     }
  893. }
  894.